import "package:flutter/material.dart";
import "MovieCardList.dart";
import "movieTitleBar.dart";

/// 影视官方推荐用户信息
class OfficialUser {
  final String avatar; //头像
  final String name; //名称
  OfficialUser({
    required this.avatar,
    required this.name,
  });
}

/// 影视官方推荐项
class MovieOfficialRecommendItem {
  String title; //标题
  OfficialUser user; //用户信息
  List<MovieCard> cardList; //卡片列表
  MovieOfficialRecommendItem({
    required this.title,
    required this.user,
    required this.cardList,
  });
}

/// 影视官方推荐 容器
class MovieOfficialRecommendWrap extends StatelessWidget {
  final List<MovieOfficialRecommendItem> itemList;
  const MovieOfficialRecommendWrap({super.key, required this.itemList});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: itemList.map((e) => MovieOfficialRecommend(item: e)).toList(),
    );
  }
}

TextStyle userNameTextStyle = const TextStyle(
  fontSize: 13,
  color: Color(0xff5a6065),
  fontWeight: FontWeight.bold,
);

class MovieOfficialRecommend extends StatelessWidget {
  final MovieOfficialRecommendItem item;
  const MovieOfficialRecommend({super.key, required this.item});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Column(
        children: [
          MovieTitleBar(leadingTitle: item.title),
          Padding(
            padding: const EdgeInsets.only(
              left: 12,
              bottom: 8,
            ),
            child: Row(
              children: [
                CircleAvatar(
                  backgroundImage: AssetImage(item.user.avatar),
                  radius: 11,
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 3),
                  child: Text(item.user.name, style: userNameTextStyle),
                ),
                Text(
                  '推荐',
                  style: userNameTextStyle,
                ),
              ],
            ),
          ),
          MovieCardList(
            cardList: item.cardList,
            size: CardSize.small,
          ),
        ],
      ),
    );
  }
}
